package com.ruoyi.project.bas.traycodehead.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.bas.traycodehead.domain.BasTraycodeHead;
import com.ruoyi.project.bas.traycodehead.service.IBasTraycodeHeadService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 条码头信息Controller
 * 
 * @author ruoyi
 * @date 2023-04-04
 */
@Controller
@RequestMapping("/bas/traycodehead")
public class BasTraycodeHeadController extends BaseController
{
    private String prefix = "bas/traycodehead";

    @Autowired
    private IBasTraycodeHeadService basTraycodeHeadService;

    @GetMapping()
    public String traycodehead()
    {
        return prefix + "/traycodehead";
    }

    /**
     * 查询条码头信息列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasTraycodeHead basTraycodeHead)
    {
        startPage();
        List<BasTraycodeHead> list = basTraycodeHeadService.selectBasTraycodeHeadList(basTraycodeHead);
        return getDataTable(list);
    }

    /**
     * 导出条码头信息列表
     */
    @Log(title = "条码头信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasTraycodeHead basTraycodeHead)
    {
        List<BasTraycodeHead> list = basTraycodeHeadService.selectBasTraycodeHeadList(basTraycodeHead);
        ExcelUtil<BasTraycodeHead> util = new ExcelUtil<BasTraycodeHead>(BasTraycodeHead.class);
        return util.exportExcel(list, "条码头信息数据");
    }

    /**
     * 新增条码头信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存条码头信息
     */
    @Log(title = "条码头信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasTraycodeHead basTraycodeHead)
    {
        return toAjax(basTraycodeHeadService.insertBasTraycodeHead(basTraycodeHead));
    }

    /**
     * 修改条码头信息
     */
    @GetMapping("/edit/{tHead}")
    public String edit(@PathVariable("tHead") String tHead, ModelMap mmap)
    {
        BasTraycodeHead basTraycodeHead = basTraycodeHeadService.selectBasTraycodeHeadByTHead(tHead);
        mmap.put("basTraycodeHead", basTraycodeHead);
        return prefix + "/edit";
    }

    /**
     * 修改保存条码头信息
     */
    @Log(title = "条码头信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasTraycodeHead basTraycodeHead)
    {
        return toAjax(basTraycodeHeadService.updateBasTraycodeHead(basTraycodeHead));
    }

    /**
     * 删除条码头信息
     */
    @Log(title = "条码头信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basTraycodeHeadService.deleteBasTraycodeHeadByTHeads(ids));
    }
}
